-------------------------------------------------------------------------------- -- Space restrictor scheme for crowkiller minigame ----------------------------- -- Made by Peacemaker ---------------------------------------------------------- -- 26.12.07 -------------------------------------------------------------------- -------------------------------------------------------------------------------- class "crowkiller" -- Class constructor function crowkiller:__init(obj, storage) self.object = obj self.st = storage self.time_for_spawn = time_global() self.spawn_points_idle = {} self.spawned_count = nil end -- On scheme switch resets all self params function crowkiller:reset_scheme() for k,v in pairs(self.st.path_table) do self.spawn_points_idle[v] = time_global() end end -- Class update function crowkiller:update(delta) -- check for spawn crows on level if(self.time_for_spawn self.spawn_points_idle[selected_path]) then local ptr = patrol(selected_path) if (ptr and ptr:point(0):distance_to_sqr(db.actor:position())>10000) then self.spawn_points_idle[selected_path] = time_global() + 10000 alife_create("m_crow", ptr:point(0), ptr:level_vertex_id(0), ptr:game_vertex_id(0)) return true end end return false end -------------------------------------------------------------------------------- -- Standart functions -------------------------------------------------------------------------------- function add_to_binder(npc, ini, scheme, section, storage) xr_logic.subscribe_action_for_events(npc, storage, crowkiller(npc, storage)) end function set_scheme(obj, ini, scheme, section, gulag_name) local st = xr_logic.assign_storage_and_bind(obj, ini, scheme, section) st.logic = xr_logic.cfg_get_switch_conditions(ini, section, obj) st.max_crows_on_level = ini:r_float_ex(section,"max_crows_on_level") or 7 local path = ini:r_string_ex(section,"spawn_path") st.path_table = path and parse_names(path) or nil end